#include "wl_mutex.h"
#include "wl_trace.h"
#include "ql_rtos.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

wl_int32 wl_mutex_create(const wl_char* name, OUT WL_MUTEX* mutex) {
    if (wl_null != mutex) {
        return ql_rtos_mutex_create(mutex);
    }

    return -1;
}

wl_int32 wl_mutex_acquire(WL_MUTEX* mutex) {
    if (wl_null != mutex) {
        return ql_rtos_mutex_lock(*mutex, QL_WAIT_FOREVER);
    }
    return -1;
}

wl_int32 wl_mutex_try_acquire(WL_MUTEX* mutex, wl_uint32 timeout) {
    if (wl_null != mutex) {
        return ql_rtos_mutex_lock(*mutex, timeout);
    }
    return -1;
}

wl_int32 wl_mutex_release(WL_MUTEX* mutex) {
    if (wl_null != mutex) {
        return ql_rtos_mutex_unlock(*mutex);
    }
    
    return -1;
}

wl_int32 wl_mutex_delete(WL_MUTEX* mutex) {
    if (wl_null != mutex) {
        return ql_rtos_mutex_delete(*mutex);
    }

    return -1;
}

#ifdef __cplusplus
}
#endif /* __cplusplus */
